package com.zx.idc.backend.gui.slog;

import com.zx.idc.backend.gui.common.MongoBaseApi;
import com.zx.idc.backend.gui.common.Result;
import com.zx.idc.ds.common.mongopage.Page;
import com.zx.idc.ds.httplog.service.IHttpLogAccessLogService;
import com.zx.idc.ds.httplog.vo.AccessLogVo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.util.HtmlUtils;


/**
 * <p>
 * 访问日志 前端控制器
 * </p>
 *
 * @author chendong
 * @since 2019/4/2
 */
@RestController
@RequestMapping("/api/slogAccessLog")
public class SlogAccessLogController extends MongoBaseApi<IHttpLogAccessLogService, AccessLogVo> {
    @GetMapping("/query-page")
    @RequiresPermissions("regulatory-log:ins-accesslog-query")
    public Result<Page<AccessLogVo>> page(Page<AccessLogVo> page, AccessLogVo accessLogVo) {
        //防止xss攻击,url被编译过的 拿到原来的数据需要反编译一下
        accessLogVo.setUrlQuery(HtmlUtils.htmlUnescape(accessLogVo.getUrlQuery()));
        return success(service.pageByParam(page, accessLogVo));
    }
}
